package com.wyc.service;

import com.wyc.util.IpUtil;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * @author
 */
@Service
public class ConsumerService {

    @Reference
    private HelloService helloService;

    @Reference
    private GoodByeService goodByeService;

    public String consumer(HttpServletRequest request, String type){
        String realIp = IpUtil.getRemoteIpByServletRequest(request, false);
        if("hello".equals(type)){
            return sayHello(realIp);
        }
        return sayGoodBye(realIp);
    }

    public String sayHello(String ip) {
        return helloService.sayHello(ip);
    }

    public String sayGoodBye(String ip){
        return goodByeService.sayGoodByeService(ip);
    }

}
